<!--{include admin/top.html}-->
	<div class="mainPage">
	<!--{if $do =='list'}-->
		<h1 class="title">导航列表
			<span class='sub_menu'>
				&nbsp; <a href="{:parse_uri('admin_other-nav-do-add')}">添加导航</a>
			</span>
		</h1>
		<table width="100%" align=center cellspacing=0 cellpadding=0 border=0>
		<tr >
			<td width="15%" align=center>
				<p><b>导航名称</b></p></td>
			<td width="45%" align=center><p><b>链接地址</b></p></td>
			<td width="15%" align=center><p><b>排序(大<code>-></code> 小)</b></p></td>
			<td width="10%" align=center><p><b>打开方式</b></p></td>
			<td width="10%" align=center><p><b>操作</b></p></td>
		</tr>
		<!--{foreach $nav $k $v}-->
		<tr class='ctr'>
			<td align=center>
				<p style="line-height:30px;">{$v['nav_title']}</p></td>
			<td  align=center>
				<p>{$v['nav_code']?parse_uri($v['nav_code']):$v['nav_url']}</p>
			</td>
			<td  align=center>
				<p>&nbsp;<input type="text" value="{$v['nav_sort']}" style='width:30px;' maxlength=3 onblur="upSort({$v['nav_sort']},this.value,{$v['Id']},this)" />
				</p>
			</td>
			<td  align=center>
				<p>
					{if $v['nav_target']=='1'}
						新窗口
					{else}
						原窗口
					{/if}
				</p>
			</td>
			<td  align=center>
				<p><a href="{:parse_uri('admin_other-nav-do-del-id-%d',$v['Id'])}">删除</a></p>
			</td>
		</tr>
		<!--{/foreach}--></table>
	<script>
	// AJAX FUNC //
	function upSort(ov,val,id,obj){
		if(!isNum(val)){
			obj.value = ov;
			return false;
		}
		ov = parseInt(ov);
		val = parseInt(val);
		if(ov == val){
			return false;
		}
		var url = '{:parse_uri("admin_other-ajax-do-navsort-id-#id#-val-#val#")}';
		url = url.replace('#id#',id).replace('#val#',val);
		$.get(url, function(data){
			if(parseInt(data)==250){
				location.reload();
			}
		});
	}
	function isNum(s){
		var patrn=/^[0-9]{1,3}$/;
		if (!patrn.exec(s)){
			return false;
		}
		return true;
	}
	</script>
	<!--{elseif $do == 'add'}-->
	<script>
	function usePage(obj){
		obj = $(obj);
		if(obj.val()=='0'){
			$("#nav_title").val('');
			$("#nav_url").val('');
			$("#nav_title").val('');
		}else{
			$("#nav_title").val(obj.text());
			$("#nav_url").val(obj.val());
		}
	}
	function show(obj,p){
		$(".chb").attr('checked',false);
		if(p == 0){
			if($("#sl_panel").css('display')=='none'){
				$("#cat_panel").css('display','none');
				$("#sl_panel").css('display','block');
				$(obj).attr('checked',true);
				
			}else{
				$("#sl_panel").css('display','none');
			}
		}else{
			if($("#cat_panel").css('display')=='none'){
				$("#sl_panel").css('display','none');
				$("#cat_panel").css('display','block');
				$(obj).attr('checked',true);
			}else{
				$("#cat_panel").css('display','none');
			}

		}
	}
	</script>
		<h1 class="title">添加导航
			<span class='sub_menu'>
				&nbsp; <a href="{:parse_uri('admin_other-nav-do-list')}">返回列表</a>
			</span>
		</h1>
		
		<form action="{:parse_uri('admin_other-nav-do-save')}" method="post">
		<p>导航名称: <input name="nav_title" id="nav_title" class="ipt"/></p>
		<p>链接地址: <input name="nav_url" id="nav_url" class="ipt"/></p>
		<p>打开方式: 新窗口 <input name="nav_target" type="radio" value="1" checked /> 
					 原窗口 <input name="nav_target" type="radio"  value="0" />
		</p>
		<p style="margin-top:10px;">其他页面: 
		自定义 <input type="checkbox" class="chb" onclick="show(this,0)" /> 
		栏目页 <input type="checkbox" class="chb" onclick="show(this,1)" /> 
		
		</p>
		<p id="sl_panel" style="display:none">
		页面列表:&nbsp;<select onchange="usePage(this.options[this.options.selectedIndex])">
				<option value=0>请选择页面</option>
				{foreach $nav $k $v}
				<option value="page-v-id-{$v['Id']}" >{$v['name']}</option>
				{/foreach}
			</select>
		</p>
		<p id="cat_panel" style="display:none">
		栏目列表:&nbsp;<select onchange="usePage(this.options[this.options.selectedIndex])">
				<option value=0>请选择栏目</option>
				<option value="pro-index|true" >产品</option>
				<option value="art-index|true" >资讯</option>
				{foreach $cats $k $v}
				<option value="{$v['cat_type']==1?'pro':'art'}-cat-id-{$v['Id']}" >{$v['cat_name']}</option>
				{/foreach}
			</select>
		</p>
		<p style='margin-top:10px;'><input type="submit" value='提交'class="submit"/></p>
		</form>
	<!--{/if}-->
		<p>
			&nbsp;
		</p>
	</div>
</body>
</html>